package com.ruoyi.life.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import com.ruoyi.common.core.utils.StringUtils;
import com.ruoyi.omp.api.domain.vo.RoomVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.life.mapper.FeApartmentLeaseDetailMapper;
import com.ruoyi.life.domain.FeApartmentLeaseDetail;
import com.ruoyi.life.service.IFeApartmentLeaseDetailService;

/**
 * 公寓房源租赁明细Service业务层处理
 *
 * @author cjie
 * @date 2022-09-13
 */
@Service
public class FeApartmentLeaseDetailServiceImpl implements IFeApartmentLeaseDetailService {
    @Autowired
    private FeApartmentLeaseDetailMapper feApartmentLeaseDetailMapper;

    /**
     * 查询公寓房源租赁明细
     *
     * @param id 公寓房源租赁明细ID
     * @return 公寓房源租赁明细
     */
    @Override
    public FeApartmentLeaseDetail selectFeApartmentLeaseDetailById(String id) {
        return feApartmentLeaseDetailMapper.selectFeApartmentLeaseDetailById(id);
    }

    /**
     * 查询公寓房源租赁明细列表
     *
     * @param feApartmentLeaseDetail 公寓房源租赁明细
     * @return 公寓房源租赁明细
     */
    @Override
    public List<FeApartmentLeaseDetail> selectFeApartmentLeaseDetailList(FeApartmentLeaseDetail feApartmentLeaseDetail) {
        return feApartmentLeaseDetailMapper.selectFeApartmentLeaseDetailList(feApartmentLeaseDetail);
    }

    /**
     * 新增公寓房源租赁明细
     *
     * @param feApartmentLeaseDetail 公寓房源租赁明细
     * @return 结果
     */
    @Override
    public int insertFeApartmentLeaseDetail(FeApartmentLeaseDetail feApartmentLeaseDetail) {
        feApartmentLeaseDetail.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        feApartmentLeaseDetail.setCreateTime(DateUtils.getNowDate());
        feApartmentLeaseDetail.setCreateBy(SecurityUtils.getUsername());
        return feApartmentLeaseDetailMapper.insertFeApartmentLeaseDetail(feApartmentLeaseDetail);
    }

    /**
     * 修改公寓房源租赁明细
     *
     * @param feApartmentLeaseDetail 公寓房源租赁明细
     * @return 结果
     */
    @Override
    public int updateFeApartmentLeaseDetail(FeApartmentLeaseDetail feApartmentLeaseDetail) {
        return feApartmentLeaseDetailMapper.updateFeApartmentLeaseDetail(feApartmentLeaseDetail);
    }

    /**
     * 批量删除公寓房源租赁明细
     *
     * @param ids 需要删除的公寓房源租赁明细ID
     * @return 结果
     */
    @Override
    public int deleteFeApartmentLeaseDetailByIds(String[] ids) {
        return feApartmentLeaseDetailMapper.deleteFeApartmentLeaseDetailByIds(ids);
    }

    /**
     * 删除公寓房源租赁明细信息
     *
     * @param id 公寓房源租赁明细ID
     * @return 结果
     */
    @Override
    public int deleteFeApartmentLeaseDetailById(String id) {
        return feApartmentLeaseDetailMapper.deleteFeApartmentLeaseDetailById(id);
    }

    @Override
    public List<FeApartmentLeaseDetail> selectFeApartmentLeaseDetailList(String recordId) {
        if(StringUtils.isNotEmpty(recordId)){
            FeApartmentLeaseDetail feApartmentLeaseDetail = new FeApartmentLeaseDetail();
            feApartmentLeaseDetail.setLeaseId(recordId);
            return feApartmentLeaseDetailMapper.selectFeApartmentLeaseDetailList(feApartmentLeaseDetail);
        }
        return null;

    }
}
